// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   EIVLImpl.java

package com.sunwayhorizo.health.hl7.datatypes.common;

import com.sunwayhorizo.health.hl7.common.Hl7Exception;
import com.sunwayhorizo.health.hl7.common.VersionInfo;
import com.sunwayhorizo.health.hl7.datatypes.ANY;
import com.sunwayhorizo.health.hl7.datatypes.BL;
import com.sunwayhorizo.health.hl7.datatypes.CS;
import com.sunwayhorizo.health.hl7.datatypes.EIVL;
import com.sunwayhorizo.health.hl7.datatypes.INT;
import com.sunwayhorizo.health.hl7.datatypes.IVL_PQ;
import com.sunwayhorizo.health.hl7.datatypes.IVL_TS;
import com.sunwayhorizo.health.hl7.datatypes.SET_TS;
import com.sunwayhorizo.health.hl7.datatypes.TS;
import com.sunwayhorizo.health.hl7.datatypes.TYPE;
import com.sunwayhorizo.health.hl7.datatypes.common.gtsparser.TimeParser;

import java.io.StringReader;

import java.util.Set;


// Referenced classes of package oracle.apps.ctb.hl7.types.common:
//            GTSBase, ANYImpl, BLImpl, CSImpl, 
//            IVL_PQImpl, IVL_TSImpl, NullFlavorImpl, STImpl, 
//            TYPEImpl

public class EIVLImpl extends GTSBase
    implements EIVL
{

    public static final String RCS_ID = "$Header: EIVLImpl.java 115.33 2005/09/16 09:23:06 amchanda noship $";
    public static final boolean RCS_ID_RECORDED = VersionInfo.recordClassVersion("$Header: EIVLImpl.java 115.33 2005/09/16 09:23:06 amchanda noship $", "oracle.apps.ctb.hl7.types.common");
    CS _event;
    IVL_PQ _offset;
    private static final EIVL nullNI = new EIVLImpl(CSImpl.valueOf("NI"));
    private static final EIVL nullOTH = new EIVLImpl(CSImpl.valueOf("OTH"));
    private static final EIVL nullNINF = new EIVLImpl(CSImpl.valueOf("NINF"));
    private static final EIVL nullPINF = new EIVLImpl(CSImpl.valueOf("PINF"));
    private static final EIVL nullUNK = new EIVLImpl(CSImpl.valueOf("UNK"));
    private static final EIVL nullASKU = new EIVLImpl(CSImpl.valueOf("ASKU"));
    private static final EIVL nullNAV = new EIVLImpl(CSImpl.valueOf("NAV"));
    private static final EIVL nullMSK = new EIVLImpl(CSImpl.valueOf("MSK"));
    private static final EIVL nullNA = new EIVLImpl(CSImpl.valueOf("NA"));
    private static final EIVL nullNASK = new EIVLImpl(CSImpl.valueOf("NASK"));

    private EIVLImpl(CS cs, IVL_PQ ivl_pq)
    {
        _event = cs;
        _offset = ivl_pq;
        _dataType = com.sunwayhorizo.health.hl7.datatypes.common.TYPEImpl.EIVL;
    }

    private EIVLImpl(CS cs)
    {
        super(cs);
        _dataType = com.sunwayhorizo.health.hl7.datatypes.common.TYPEImpl.EIVL;
    }

    public static EIVL valueOf(CS cs, IVL_PQ ivl_pq)
    {
        return new EIVLImpl(cs, ivl_pq);
    }

    public static EIVL valueOf(String s)
        throws Hl7Exception
    {
        StringReader stringreader = new StringReader(s);
        TimeParser timeparser = new TimeParser(stringreader);
        try
        {
            EIVL eivl = timeparser.eivl();
            GTSBase.checkParserState(timeparser);
            ((GTSBase)eivl)._literal = STImpl.valueOf(s);
            ((GTSBase)eivl)._dataType = com.sunwayhorizo.health.hl7.datatypes.common.TYPEImpl.EIVL;
            return eivl;
        }
        catch(Throwable throwable)
        {
            throw ANYImpl.newParseException("EIVL", s, throwable);
        }
    }

    public static EIVL nullEIVL()
    {
        return new EIVLImpl(NullFlavorImpl.NA);
    }

    public TYPE dataType()
    {
        return _dataType;
    }

    public BL equal(ANY any)
    {
        if(!(any instanceof EIVL))
            return BLImpl.FALSE;
        if(isNull().or(any.isNull()).isTrue())
        {
            return BLImpl.FALSE;
        } else
        {
            EIVL eivl = (EIVL)any;
            return event().equal(eivl.event()).and(offset().equal(eivl.offset()));
        }
    }

    public CS event()
    {
        return _event;
    }

    public IVL_PQ offset()
    {
        return _offset;
    }

    public INT cardinality()
    {
        throw ANYImpl.newUnsupportedException("EIVL", "cardinality");
    }

    public BL contains(TS ts)
    {
        throw ANYImpl.newUnsupportedException("EIVL", "contains");
    }

    public BL contains(SET_TS set_ts)
    {
        throw ANYImpl.newUnsupportedException("EIVL", "contains");
    }

    public BL isEmpty()
    {
        throw ANYImpl.newUnsupportedException("EIVL", "isEmpty");
    }

    public BL nonEmpty()
    {
        return isEmpty().not();
    }

    public BL notEmpty()
    {
        return isEmpty().not();
    }

    public SET_TS except(TS ts)
    {
        throw ANYImpl.newUnsupportedException("EIVL", "except");
    }

    public SET_TS except(SET_TS set_ts)
    {
        throw ANYImpl.newUnsupportedException("EIVL", "except");
    }

    public SET_TS intersection(SET_TS set_ts)
    {
        throw ANYImpl.newUnsupportedException("EIVL", "intersection");
    }

    public SET_TS union(SET_TS set_ts)
    {
        throw ANYImpl.newUnsupportedException("EIVL", "union");
    }

    public SET_TS union(TS ts)
    {
        throw ANYImpl.newUnsupportedException("EIVL", "union");
    }

    public SET_TS promotion(TS ts)
    {
        throw ANYImpl.newUnsupportedException("EIVL", "promotion");
    }

    public IVL_TS hull()
    {
        return IVL_TSImpl.nullIVL_TS(NullFlavorImpl.NA);
    }

    public Set toSet()
    {
        throw ANYImpl.newUnsupportedException("EIVL", "toSet");
    }

//    public XMLNode[] writeXML(XMLDocument xmldocument, String s)
//        throws Hl7Exception
//    {
//        try
//        {
//            XMLElement xmlelement = (XMLElement)xmldocument.createElement(s);
//            if(event() != null && event().isNull().isFalse())
//                xmlelement.appendChild(((CSImpl)event()).writeXML(xmldocument, "event")[0]);
//            if(offset() != null && offset().isNull().isFalse())
//                xmlelement.appendChild(((IVL_PQImpl)offset()).writeXML(xmldocument, "offset")[0]);
//            return (new XMLNode[] {
//                xmlelement
//            });
//        }
//        catch(Exception exception)
//        {
//            throw new Hl7Exception(exception);
//        }
//    }

    public static EIVL nullEIVL(CS cs)
    {
        String s = null;
        if(cs == null || cs.literal().stringValue() == null || cs.isNull().isTrue())
            s = "NI";
        else
            s = cs.literal().stringValue();
        if(s.equals("NI"))
            return nullNI;
        if(s.equals("OTH"))
            return nullOTH;
        if(s.equals("NINF"))
            return nullNINF;
        if(s.equals("PINF"))
            return nullPINF;
        if(s.equals("UNK"))
            return nullUNK;
        if(s.equals("ASKU"))
            return nullASKU;
        if(s.equals("NAV"))
            return nullNAV;
        if(s.equals("MSK"))
            return nullMSK;
        if(s.equals("NA"))
            return nullNA;
        if(s.equals("NASK"))
            return nullNASK;
        else
            return nullNI;
    }

}
